package auctionhaus
//Authors: Paul Kleczka, Adam Backstrom

import static org.junit.Assert.*
import org.junit.*

class CustomerIntegrationTests {

    @Before
    void setUp() {
        // Setup logic here
    }

    @After
    void tearDown() {
        // Tear down logic here
    }

    @Test
    //C-2: Email address must be a unique field
    public void testForUniqueEmail(){
        def password = 'password'
        def email = "adambackstrom@gmail.com"

        Customer customer1 = new Customer(password: password, email: email, enabled: true)
        Customer customer2 = new Customer(password: password, email: email, enabled: true)

        customer1.save(flush: true)
        assert customer1.validate()
        assert !customer1.errors.hasErrors()

        customer2.save(flush: true)
        assert !customer2.validate()
        assert 'unique' == customer2.errors['email'].code
    }
}
